import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'
import { title } from '@/settings'

export const constantRoutes = [

  {
    path: '/',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  
  {
    path:"/",
    component: Layout,
    redirect: '/',
    children: [{
      path:"/",
      component: () => import('@/views/dashboard'),
    }]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

    

    {
      path: '/emp-report',
      component: Layout,
      redirect: '/emp-report',
      children: [{
        path: '/emp-report',
        name: 'emp-report',
        component: () => import('@/views/emp-report/index.vue'),
      }]
    },  

    {
      path:"/AddAndUpdate",
      component: Layout,
      redirect: '/goods/AddAndUpdate',
      children: [{
        path:"/goods/AddAndUpdate",
        component: () => import('../views/goods/AddAndUpdate.vue'),
      }]
    },
    
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },


  
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'el-icon-s-home el-icon-s' }
    }]
  },

  {
    path: '/AdminManage',
    component: Layout,
    redirect: '/AdminManage',
    name: 'AdminManage',
    meta: { title: '管理员管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'AdminManage',
        name: 'AdminManage',
        component: () => import('../views/admin/AdminManage.vue'),
        meta: { title: '管理员管理', icon: 'el-icon-menu' }
      }
    ]
  },

  {
    path:"/update",
    component: Layout,
    redirect: '/AdminManage/update',
    children: [{
      path:"/AdminManage/update",
      component: () => import('../views/admin/update.vue'),
    }]
  },

  

  {
    path: '/UserManage',
    component: Layout,
    redirect: '/UserManage',
    name: 'UserManage',
    meta: { title: '用户管理', icon: 'el-icon-user' },
    children: [
      {
        path: 'UserManage',
        name: 'UserManage',
        component: () => import('../views/user/UserManage.vue'),
        meta: { title: '用户管理', icon: 'el-icon-user' }
      },
    ]
  },


  
  {
    path: '/StorageManage',
    component: Layout,
    redirect: '/StorageManage',
    name: 'StorageManage',
    meta: { title: '仓库管理', icon: 'el-icon-bell' },
    children: [
      {
        path: 'StorageManage',
        name: 'StorageManage',
        component: () => import('../views/storage/StorageManage.vue'),
        meta: { title: '仓库管理', icon: 'el-icon-setting el-icon' }
      },
    ]
  },


  {
    path: '/GoodsCategoryManage',
    component: Layout,
    redirect: '/GoodsCategoryManage',
    name: 'GoodsCategoryManage',
    meta: { title: '商品分类管理', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'GoodsCategoryManage',
        name: 'GoodsCategoryManage',
        component: () => import('../views/goodscategory/GoodsCategoryManage.vue'),
        meta: { title: '商品分类管理', icon: 'el-icon-s-tools' }
      }
    ]
  },


  {
    path: '/GoodsManage',
    component: Layout,
    redirect: '/GoodsManage',
    name: 'GoodsManage',
    meta: { title: '商品管理', icon: 'el-icon-s-goods' },
    children: [
      {
        path: 'GoodsManage',
        name: 'GoodsManage',
        component: () => import('../views/goods/GoodsManage.vue'),
        meta: { title: '商品管理', icon: 'el-icon-s-goods' }
      },
    ]
  },

  {
    path: '/RecordingManage',
    component: Layout,
    redirect: '/RecordingManage',
    name: 'RecordingManage',
    meta: { title: '记录管理', icon: 'el-icon-bell' },
    children: [
      {
        path: 'RecordingManage',
        name: 'RecordingManage',
        component: () => import('../views/recording/RecordingManage.vue'),
        meta: { title: '记录管理', icon: 'el-icon-bell' }
      },
    ]
  },
  {
    path: '/emp-report/update',
    component: Layout,
    redirect: '/emp-report/update',
    name: 'update',
    children: [
      {
        path: '/emp-report/update',
        name: 'update',
        component: () => import('@/views/emp-report/update.vue'),
      },
    ]
  }
 
  // 404 page must be placed at the end !!!
  ,{ path: '*', redirect: '/404', hidden: true }
  
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})



const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
